require "event_editor/gadgets/switch_button"
require 'gadgets/combobox'

module EventEditor
  module Conditions
    class SelfSwitch < Gtk::VBox
      def initialize(base, model)
        super()
        @model = model

        box = Gtk::HBox.new
        @@self_switch_combobox = ::Gadgets::Combobox.new($config.self_switches, [String, Integer])
        box.pack_start(@@self_switch_combobox, false, false)
        box.pack_start(Gtk::Label.new("is"))
        @@combobox = ::Gadgets::Combobox.new([['ON', 'on'], ['OFF', 'off']], [String, String])
        box.pack_start(@@combobox, false, false)
        self.add(box)
      end
      
      def commands
        return ['self_switch', @@self_switch_combobox.selected_data, @@combobox.selected_data]
      end
      
      def self.load(command)
        @@self_switch_combobox.select(command[1])
        @@combobox.select(command[2])
      end
      
      def self.command_to_s(model, args)
        arr = {'on' => 'ON', 'off' => 'OFF'}
        return "Self Switch : " + $config.self_switches[args[1]][0] + " is " + arr[args[2]]
      end
    end
  end
end